#include<cstdio>
#include<cstdlib>
const int maxn=100007;
int a[6],ans=0;
typedef struct node
{
	int data;
	struct node *next;
}link;
link *h[maxn+1];
void insert(int now)
{
	int hash;
	link *p;
	if(now>=0)hash=now%maxn;
	else hash=(-now)%maxn;
	p=(link *)malloc(sizeof(link));
	p->data=now;
	p->next=h[hash];
	h[hash]=p;
}
void find(int now)
{
	int hash;
	link *p;
	if(now>=0)hash=now%maxn;
	else hash=(-now)%maxn;
	p=h[hash];
	while(p!=NULL)
	{
		if(p->data==now){ans++;}
		p=p->next;
	}
}


int main()
{
	freopen("test.in","r",stdin);
	for(int i=1;i<=5;i++)
		scanf("%d",&a[i]);
	for(int x1=-50;x1<=50;x1++)
		for(int x2=-50;x2<=50;x2++)
			if(x1!=0&&x2!=0)
			{
				int now=a[1]*x1*x1*x1+a[2]*x2*x2*x2;
				insert(now);
			}
	for(int x3=-50;x3<=50;x3++)
		for(int x4=-50;x4<=50;x4++)
			for(int x5=-50;x5<=50;x5++)
				if(x3!=0&&x4!=0&&x5!=0)
				{
					int now;
					now=-(a[3]*x3*x3*x3+a[4]*x4*x4*x4+a[5]*x5*x5*x5);
					find(now);
				}
	printf("%d\n",ans);
	return 0;
}

